home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-24 | 3.0 KB | 88 lines | [TEXT/MPS ] |
- /*
- * MControlPanel.cp (MPW 3.2)
- * Copyright ©1991 David Kreindler. All rights reserved.
- *
- * KNOWN BUGS AND SHORTCOMINGS:
- * [none]
- */
-
- #ifndef __DEVICES__
- #include <Devices.h>
- #endif
-
- #ifndef __USCANCDEV__
- #include "UScanCDEV.h" // !!! this directive will vary according to the TControlPanel subclass used
- #endif
-
- #ifndef __USTANDALONE__
- #include <UStandAlone.h>
- #endif
-
- pascal long cdev_entry(short message, short item, short numItems, short, // the linker will see this as CDEV_ENTRY
- EventRecord *theEvent, long cdevValue, DialogPtr cpDialog) {
- static TScanCDEV *cdev; // !!! this declaration will vary according to the TControlPanel subclass used
- TStandAloneWorld *a5World;
- if (message == macDev)
- cdev->DoMac(&cdevValue); // TCDEF::DoMac() is static, so we do not need an A5 world to reference it
- else if (message == initDev)
- if (a5World = new TStandAloneWorld) { // construct our A5 world
- a5World->Enter(); // swap in our A5 world
- if (cdev = new TScanCDEV(cpDialog, numItems)) { // construct our cdev; !!! this instantiation will vary according to the TControlPanel subclass used
- cdevValue = (long)a5World; // store our A5 world reference in cdevValue
- cdev->DoInit(&cdevValue);
- a5World->Leave(); // restore the caller’s A5 world
- }
- else { // we could not allocate our cdev
- cdevValue = cdevMemErr; // signal the error
- delete a5World; // dispose of our A5 world
- }
- }
- else // we could not allocate our A5 world
- cdevValue = cdevMemErr; // signal the error
- else {
- (a5World = (TStandAloneWorld *)cdevValue)->Enter(); // grab our A5 world reference from cdevValue and swap it in
- switch (message) {
- case hitDev:
- cdev->DoHit(item - numItems, theEvent, &cdevValue);
- break;
- case closeDev:
- delete cdev; // dispose of our TControlPanel instance
- delete a5World; // dispose of our A5 world; (the destructor calls Leave() for us)
- return cdevUnset; // we must return here to preclude the call to a5World->Leave(), since a5World has been destructed
- case nulDev:
- cdev->DoNull(theEvent, &cdevValue);
- break;
- case updateDev:
- cdev->DoUpdate(&cdevValue);
- break;
- case activDev:
- cdev->DoActivate(theEvent, &cdevValue);
- break;
- case deactivDev:
- cdev->DoDeactivate(theEvent, &cdevValue);
- break;
- case keyEvtDev:
- cdev->DoKeyEvent(theEvent, &cdevValue);
- break;
- case undoDev:
- cdev->DoUndo(&cdevValue);
- break;
- case cutDev:
- cdev->DoCut(&cdevValue);
- break;
- case copyDev:
- cdev->DoCopy(&cdevValue);
- break;
- case pasteDev:
- cdev->DoPaste(&cdevValue);
- break;
- case clearDev:
- cdev->DoClear(&cdevValue);
- break;
- case cursorDev:
- cdev->DoCursor(&cdevValue);
- }
- a5World->Leave(); // restore the caller’s A5 world
- }
- return cdevValue; // report our status
- }